import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';

class TstLoading extends StatefulWidget {
  @override
  _TstLoadingSate createState() => _TstLoadingSate();
}

class _TstLoadingSate extends State<TstLoading> {
  var control = {'needLoadMore': true};

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(
          title: Text('Loading框'),
        ),
        body: _buildProgressIndicator());
  }

  Widget _buildProgressIndicator() {
    ///是否需要显示上拉加载更多的loading
    Widget bottomWidget = (control['needLoadMore'])
        ? new Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
                ///loading框
                SpinKitCircle(
                  itemBuilder: (_, int index) {
                    return DecoratedBox(
                      decoration: BoxDecoration(
                        color: index.isEven ? Colors.red : Colors.green,
                      ),
                    );
                  },
                ),

                SpinKitHourGlass(
                  color: Colors.indigo,
                ),
                new Container(
                  width: 5.0,
                ),

                ///加载中文本
                new Text(
                  "加载中···",
                  style: TextStyle(
                    color: Color(0xFF121917),
                    fontSize: 14.0,
                    fontWeight: FontWeight.bold,
                  ),
                )
              ])

        /// 不需要加载
        : new Container();
    return new Padding(
      padding: const EdgeInsets.all(20.0),
      child: new Center(
        child: bottomWidget,
      ),
    );
  }




}
